#ifndef __OS_MEMBLOCK_H
#define __OS_MEMBLOCK_H

#include "osevent.h"


typedef struct _MEMBLOCK
{
    EVENT_T     event;          // 事件等待队列
    void*       memStart;       // 存储区首地址
    uint32_t    blockSize;      // 存储块大小
    uint32_t    maxCount;       // 最大存储块数量
    LIST_T      blockList;      // 存储块队列
} MEMBLOCK_T;

typedef struct _MEMBLOCK_INFO {
    uint32_t    count;          // 空闲存储块数量    
    uint32_t    maxCount;       // 最大存储块数量
    uint32_t    blockSize;      // 存储块大小
    uint32_t    taskCount;      // 事件等待队列的任务数量

} MEMBLOCK_INFO_T;


extern void     vMemBlockInit(MEMBLOCK_T *memBlock, uint8_t * memStart, uint32_t blockSize, uint32_t maxCount);
extern uint32_t vMemBlockWait(MEMBLOCK_T *memblock, uint8_t **mem, uint32_t timeout);
extern uint32_t vMemBlockNoWait(MEMBLOCK_T *memblock, uint8_t **mem);
extern void     vMemBlockNotify(MEMBLOCK_T *memblock, uint8_t *mem);
extern uint32_t vMemBlockDestroy(MEMBLOCK_T *memblock);
extern void     vMemBlockGetInfo(MEMBLOCK_T *memblock, MEMBLOCK_INFO_T *info);

#endif // __OS_MEMBLOCK_H
